const express = require('express')
// 引入处理formdate格式的包
const multer = require('multer')
// 引入express-joi包
const expressJoi=require('@escook/express-joi')
const path=require('path')
const upload=multer({dest:path.join(__dirname,'../uploads')})
const router = express.Router()
// 引入路由处理函数
const {addArticle}=require('../router_handler/article')
// 引入文章信息接口校验规则
const {addArticleRuler}=require('../schema/article')
// 发表新文章
//注册局部中间件,用来解析
// 注意:应用参数校验规则需要放在multer中间件之后
router.post('/article/add',upload.single('cover_img'), expressJoi(addArticleRuler),addArticle)

//导出路由
module.exports=router